﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Police.Rules
{
    [PreCommitRule(RuleName, 0)]
    public sealed class CheckDevPermissionsRule : IPreCommitRule
    {
        public const String RuleName = "Check Dev Permissions";

        public void Validate(Configuration.Settings settings, Svn.ISvnChangeInfo changeInfo)
        {
            var dev = settings.Developers.FirstOrDefault(d => d.Username == changeInfo.Author);
            if (dev == null)
                throw new PreCommitRuleException(RuleName, "You are not authorized to execute this commit.");
        }
    }
}
